package com.comparable_comparator.arraylist;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

class Customer implements Comparable<Customer>{
	private int cid;
	private String cname;
	private long phone;
	private String email;
	public int getCid() {
		return cid;
	}
	Customer(){}
	public Customer(int cid, String cname, long phone, String email) {
		super();
		this.cid = cid;
		this.cname = cname;
		this.phone = phone;
		this.email = email;
	}

	public void setCid(int cid) {
		this.cid = cid;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public long getPhone() {
		return phone;
	}
	public void setPhone(long phone) {
		this.phone = phone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String toString(){
		return cid+"\t"+cname+"\t"+phone+"\t"+email;
	}
	@Override
	public int compareTo(Customer o) {
		//Customer c=(Customer)o;
		//int id=c.cid;
		return this.cid-o.cid;
	}
}
public class CustomerExample {
public static void main(String[] args) {
	ArrayList<Customer> al=new ArrayList<Customer>();
	al.add(new Customer(101, "deepak", 9999999, "deepak@symp.com"));
	al.add(new Customer(108, "amit", 8778787, "amit@tcs.com"));
	al.add(new Customer(106, "raman", 4343434, "raman@technotree.com"));
	al.add(new Customer(103, "avinash", 990999, "avi@tavant.com"));
	
	
	
	Collections.sort(al);
	for(Customer cust:al){
		System.out.println(cust);
	}
	
}
}
